#!/bin/bash

# refer https://linktimecloud.github.io/kubernetes-data-platform/docs/zh/catalog-overview/Hive/overview.html


# Kubernetes镜像源配置

# 导入 gpg key： 
apt-get update && apt-get install -y apt-transport-https
curl -fsSL https://mirrors.aliyun.com/kubernetes-new/core/stable/v1.30/deb/Release.key |
    gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://mirrors.aliyun.com/kubernetes-new/core/stable/v1.30/deb/ /" |
    tee /etc/apt/sources.list.d/kubernetes.list
apt-get update
apt-get install -y kubelet kubeadm kubectl




# 关闭防火墙，禁用防火墙开机自启动
apt install ufw
ufw status
ufw disable
# 临时关闭Swap
swapoff -a





# 安装 minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
sudo dpkg -i minikube_latest_amd64.deb




# docker 提前拉取 kicbase 
docker pull registry.cn-beijing.aliyuncs.com/google_containers/kicbase:v0.0.44



# 删除并重新启动 -- https://kubernetes.io/zh-cn/releases/patch-releases/
## 阿里安装wiki：https://github.com/AliyunContainerService/minikube/wiki
## 阿里镜像：https://cr.console.aliyun.com/cn-beijing/instances/mirrors

minikube delete --all --purge ; minikube start --cpus=4 --memory=4096mb --registry-mirror='https://cqrytl8b.mirror.aliyuncs.com' --base-image='registry.cn-beijing.aliyuncs.com/google_containers/kicbase:v0.0.44'
#--force是以root身份启动的docker的必须选项
#--memory=1690mb 是因为资源不足需要添加的限制性参数，可忽略
#--base-image为指定minikube start 采用的基础镜像，上面docker pull拉取了什么镜像，这里就改成什么镜像




#  打开k8s的管理界面
minikube addons enable metrics-server
minikube dashboard --alsologtostderr -v=1


# Minikube 查看 Addon 组件
minikube addons list
minikube addons enable ingress
minikube addons enable ingress-dns


# 查看节点日志
kubectl get pods --all-namespaces
kubectl logs --namespace=kubernetes-dashboard  kubernetes-dashboard-779776cb65-2hj2n 

kubectl describe --namespace=kubernetes-dashboard po kubernetes-dashboard-6f4c897964-gzmwn










